#include <iostream>
#include <iomanip>
#include <algorithm>
#include <iterator>
#include <vector>

#include "grades.hpp"

using std::begin;
using std::end;

int main()
{
    std::vector<double> v;  // or better "grade_vector v", but we'll make some changes next
    // Data is read from stdin as a list of real numbers separated by whitespace
    // If not redirected from a file or read from a pipe, use Ctrl-D to send EOF
    read_grade_vector(std::cin, v);
    double m = median(v);
    double a = average(v);
    std::cout << std::setprecision(2) << std::fixed;
    std::cout << "Grades  = [ ";
    std::copy(begin(v), end(v), std::ostream_iterator<double>(std::cout, " "));
    std::cout << "]" << std::endl;
    std::cout << "Median  = " << m << std::endl;
    std::cout << "Average = " << a << std::endl;
    return 0;
}
